<!--
 * @Author: windys
 * @Description: 
 * @Date: 2021-12-03 13:43:20
-->
<template>
    <div>
        <a-button @click="onCopy" type="primary">复制</a-button>
        <a-button type="primary" v-debounce="[handleTest]" style="margin:0 5px">按钮防抖</a-button>
    </div>
</template>


<script lang="ts">
import { computed, defineComponent, onMounted, ref, unref } from 'vue'
import { useCopyToClipboard } from '../../hook/useCopyToClipboard';
export default defineComponent({
    setup() {
        const copyVal = ref("")
        const { clipboardRef, copiedRef } = useCopyToClipboard();
        const onCopy = (e: any) => {
            const value = unref(copyVal);
            if (!value) {
                console.log('请输入要拷贝的内容！');
                return;
            }
            clipboardRef.value = value;
            if (unref(copiedRef)) {
                console.log('copy success！');
            }
        }
        const onError = () => {

        }
        const handleTest = () => {
            console.log('按钮防抖')
        }
        const checked = ref<boolean>(false);

        const source = ref('Hello')
        return {
            onCopy,
            handleTest,
            checked,


        }
    },
})
</script>
